/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package model;

/**
 *
 * @author SONY
 */
public class UserService {
    
    UserDAO userDAO;
    
    public UserService() {
        userDAO = new UserDAO();
    }
    
    public User checkLogin(String login_email, String login_password) {
        return userDAO.search(login_email, login_password);
    }
    
    public boolean checkEmail(String email) {
        return userDAO.searchEmail(email);
    }
    
    public boolean addUser(String email, String password, int memberid) {
        try {
            if(userDAO.insert(email, password, memberid)) {
                return true;
            }
        } catch (Exception e) {
            System.err.println(e);
        }
        return false;
    }
    
    public boolean changePassword(String email, String password) {
        try {
            if(userDAO.update_Password(email, password)) {
                return true;
            }
        } catch (Exception e) {
            System.err.println(e);
        }
        return false;
    }
    
    public boolean checkPassword(String email, String password) {
        User user = userDAO.search(email, password);
        if(user != null) {
            return true;
        } else {
            return false;
        }
    }
}
